#include "GuiPlugin1ConfigPanel.h"
#include <plugin/util/Framework.h>

using namespace antu::plugin;

#include <QFormLayout>

GuiPlugin1ConfigPanel::GuiPlugin1ConfigPanel()
{
    QFormLayout* pLayout = new QFormLayout;
    this->setLayout(pLayout);

    this->m_pName = new QLineEdit;
    this->m_pNumber = new QSpinBox;
    this->m_pNumber->setMaximum(100);
    this->m_pNumber->setMinimum(1);

    pLayout->addRow("Text", this->m_pName);
    pLayout->addRow("Number", this->m_pNumber);
}

void GuiPlugin1ConfigPanel::save() const
{
    Framework::Instance.settingsManager()->setValue("gui1/name", this->m_pName->text());
    Framework::Instance.settingsManager()->setValue("gui1/value", this->m_pNumber->value());
}

void GuiPlugin1ConfigPanel::load()
{
    this->m_pName->setText(Framework::Instance.settingsManager()->value("gui1/name", "name").toString());
    this->m_pNumber->setValue(Framework::Instance.settingsManager()->value("gui1/value", 2).toInt());
}

quint64 GuiPlugin1ConfigPanel::computeContentHash() const
{
    return (quint64)this->m_pNumber->value();
}
